<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
    <link rel="stylesheet" href="../assets/css/index.css"/>
</head>
<body>
<h1>extends</h1>
<hr>
<div id="app">
    {{message}}
    {{message2}}
    <p>
        <button @click="jia">+</button>
    </p>
</div>

<script>
    Vue.mixin({
        created: function () {
            console.log('我是全局被混入的')
        }
    })

    var aaa = {
        data: {
            message: 'mixins',
            message2: 'mixins222'
        },
        created: function () {
            this.message = "我被混入了"
            console.log('我是被混入的')
        },
        methods: {
            jia: function () {
                console.log('加了,混入的')
            }
        }
    }

    var bbb = {
        created: function () {
            console.log('我是被扩展的')
        },
        methods: {
            jia: function () {
                console.log('我是被扩展出来的方法')
            }
        }
    }

    var vm = new Vue({
        el: '#app',
        data: {
            message: 'hello Vue'
        },
        methods: {
            jia: function () {
                console.log('加了')
            }
        },
        created: function () {
            console.log('我是构造器里的')
        },
        extends: bbb,//只能加一个
        mixins: [aaa]
    })
</script>
</body>
</html>